<?php session_start();?>
<!DOCTYPE HTML/>
<html>
	<meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
	<head>
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
		<?php include "include.php"?>
	</head>
	<body onload="set_menu('exam');">
		<?php include "header.php";
			include "connect.php";
			
			$query="SELECT * FROM post ORDER BY no DESC";
			$result=mysql_query($query);
			$totalPost=mysql_num_rows($result);
		?>
		
		<div class="container">
			<div class="text-center">
				<h1>Past Exam Papers <a href="#upload" role="button" data-toggle="modal" class="btn btn-large btn-inverse">Share</a></h1>
				기출문제를 업로드, 다운로드 할 수 있습니다.
			</div>
			<!-- Modal -->
			<form class="form-input form-inline">
				<div id="upload" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
						<h3 id="myModalLabel">Upload Files</h3>
					</div>
					<div class="modal-body">
						<p>해당 과목의 이름, 교수님, 연도, 학기, 분류를 선택하고 파일을 첨부해주세요.</p>
						<div>
						<strong>과목명</strong>
						<input type="text" class="form-control3" required/>
										
						<strong>교수님</strong>
						<input type="text" class="form-control2" required/><br/>
						
						<strong>연도</strong>
						<input type="text" class="form-control1" placeholder="2013" required/>&nbsp;&nbsp;
							
						<strong>학기</strong>
						<input type="text" class="form-control1" placeholder="가을" required/>&nbsp;&nbsp;
											
						<strong>분류</strong>
						<input type="text" class="form-control2" placeholder="기말고사" required/><br/>
						</div>
						<input type="file" class="pull-right" required/>
					</div>
					<div class="modal-footer">
						<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
						<input type="submit" class="btn btn-inverse" value="Upload"/>
					</div>
				</div><!-- /.Modal -->	
			</form>		
			<br/>
			<form class="form">
			<table class="table table-hover table-center">
				<tr>
					<th>과목명</th>
					<th>교수님</th>
					<th>분류</th>
					<th>좋아요</th>
					<th>파일</th>
				</tr>
				<tr>
					<td><input class="form-control" type="text"/></td>						
					<td><input class="form-control" type="text"/></td>
					<td><input class="form-control" type="text"/></td>
					<td><input class="form-control" type="text"/></td>
					<td><input class="form-control" type="text"/></td>
				</tr>
			<?php 
				for($i=0; $i<$totalPost; $i++){
					mysql_data_seek($result, $i);
					$row=mysql_fetch_array($result);
					$time=strtok($row[time], " ");
					echo '
					<tr>
						<td>'.$row[title].'</td>
						<td>'.$row[writer].'</td>
						<td>2013년 가을 기말고사</td>
						<td><i class="icon-thumbs-up-alt"></i> '.$row[hit].'</td>	
						<td><span class="badge badge-important">pdf</span></td>	
					</tr>
					';
				}
			?>
			</table>	        
			</form>
      </div>				
	<script src="js/menu.js"></script>
	</body>
</html>